/* dig.h
 * The dig module contains functions for analyzing a map to determine
 * appropriate locations to dig dungeon elements such as rooms and
 * tunnels. They can then modify the map to insert these dungeon 
 * structures. All dig functions will extend the map as necessary.
 * To ensure correct operation of all functions in this module,
 * the map must not have been modified manually in between calls to
 * dig functions. dig_init must be called before any calls to any of
 * these functions is made for the first time.
 */
#ifndef DIG_H_
#define DIG_H_

#include "rect.h"
#include "map.h"

// Call these at the beginning/end of all digging operations
void dig_init (Map* m);
void dig_cleanup ();

/*
 * This function will attempt to place a rectangular shaped room of the
 * given dimensions in a free area of the map near the specified
 * coordinates, preferably on the same z layer.
 */
Rect dig_room (int width, int height, coord_t near);

/*
 * This function will attempt to dig an empty corridor tunnel from the
 * coordinates from_x/from_y/from_z to to_x/to_y/to_z, crossing at
 * most max_length previously TILE_UNDEFINED map tiles (not counting
 * the wall tiles framing the corridor). It is expected that the 
 * from/to coordinates point to locations that lie within previously
 * placed rooms. The algorithm will therefore first find a suitable 
 * wall to breach out into the TILE_UNDEFINED areas at either end of 
 * the corridor to keep it short.
 * is_room is a function that returns true if the given coordinates lie
 * within a room that belongs to a segment, except SEGMENT_CORRIDOR,
 * and false everywhere else.
 */
void dig_tunnel (coord_t from, coord_t to, int (*is_room) (coord_t));

#endif
